﻿using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Framework.Security;

namespace Pixysoft.Framework.Remoting.testdriven
{
    class quickstart
    {
        public void deploy_security()
        {
            //使用默认的用户名、密码 

            //此默认在Security框架内的TokenHelper有描述

            string username = "helloworld";
            string password = "helloworld";
            string md5 = Pixysoft.Security.MD5.GetMD5(password);
            Console.WriteLine(md5);

            //部署权限框架

            TokenSecurityManager.Instance.Restart();
            string token = TokenSecurityManager.Instance.Login(username, md5);
            Console.WriteLine(token);
            Console.WriteLine(TokenSecurityManager.Instance.Register(token, "test", Pixysoft.Security.MD5.GetMD5("test")));


            //把生成的helloworld.db拷贝到网站的目录下
        }

        public void remotecall()
        {
            //启动Remoting.Demo 网站，获取url

            string url = "http://localhost:4892/Pixysoft.Framework.Remoting.Demo/remoting.asmx";

            IRemoteChannel<IRemotingHelloworld> remoting = RemotingManager.CreateRemoteChannel<IRemotingHelloworld>(url);

            remoting.Login("helloworld", "helloworld");

            IRemotingValue value = Pixysoft.Tools.PojoHelper.GetPojo<IRemotingValue>();

            IRemotingValue response = remoting.RemoteProxy.HelloWorld(DateTime.Now, "hello", 3, value);

            Console.WriteLine(response.DateTimeValue);
            Console.WriteLine(response.StringValue);
            Console.WriteLine(response.IntValue);
            Console.WriteLine(response.Value);


        }
    }
}
